﻿using System.Data;
using System.Windows.Forms;
using DevExpress.Utils;
using HouseRental.DataSets;

namespace HouseRental.Controls
{
    public partial class ChangeHouseRental : Form
    {
        public CondominioDataSet HouseRentalData
        {
            set { SetupHouseRentalData(value); }
        }

        public string HouseRentalName
        {
            get { return houseRentalLookUpEdit.Text; }
        }

        public string HouseRentalId
        {
            get { return houseRentalLookUpEdit.EditValue.ToString(); }
        }

        private void SetupHouseRentalData(DataSet houseRentalData)
        {
            condominioDataSet.Clear();
            condominioDataSet.Merge(houseRentalData);
            houseRentalLookUpEdit.Properties.DataSource = condominioDataSet.Condomínio;
            houseRentalLookUpEdit.Properties.DisplayMember = condominioDataSet.Condomínio.NomeColumn.ToString();
            houseRentalLookUpEdit.Properties.ValueMember = condominioDataSet.Condomínio.IdColumn.ToString();
            houseRentalLookUpEdit.Properties.Columns.Clear();
            houseRentalLookUpEdit.Properties.Columns.AddRange(new[] {
                new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Nome", "Nome", 70, FormatType.None, "", true, HorzAlignment.Near)});
            houseRentalLookUpEdit.ClosePopup();
        }
        
        public ChangeHouseRental()
        {
            InitializeComponent();
        }
    }
}
